package com.vision.web.controller.v91;

import com.alibaba.fastjson.JSON;
import com.vision.common.bean.CommonResult;
import com.vision.common.bean.Pagination;
import com.vision.common.bean.msg91.Video91QueryOrder;
import com.vision.common.util.HttpIPUtil;
import com.vision.entity.msg91.Video91Msg;
import com.vision.service.Msg91Service;
import com.vision.web.annotation.Decode;
import com.vision.web.annotation.Encode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Filename Msg91Controller.java
 * @Description
 * @Version 1.0
 * @Author zhongc
 * @Email zhong_ch@foxmail.com
 * @History <li>Author: zhongc</li>
 * <li>Date: 2017/5/22</li>
 * <li>Version: 1.0</li>
 * <li>Content: create</li>
 */
@RestController
public class Msg91Controller {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Resource
    private Msg91Service msg91Service;

    @Encode
    @RequestMapping("91search")
    public String search91Msg(@Decode String params, HttpServletRequest request) throws Exception {
        request.getSession();
        String ipAddr = HttpIPUtil.getIpAddr(request);
        logger.info("request ip:{},Msg91Controller.search91Msg request params:{}", ipAddr, params);
        // throw new Exception("我操");
        Video91QueryOrder queryOrder = JSON.parseObject(params, Video91QueryOrder.class);
        CommonResult<Pagination<Video91Msg>> result = msg91Service.search91VideoMsg(queryOrder);
        return JSON.toJSONString(result);
    }

}
